package com.ruoyi.develop.produceRecordDetail.service.impl;

import java.util.List;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.DateUtils;
        import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.ruoyi.develop.produceRecordDetail.mapper.ProduceRecordDetailMapper;
import com.ruoyi.develop.produceRecordDetail.domain.ProduceRecordDetail;
import com.ruoyi.develop.produceRecordDetail.service.IProduceRecordDetailService;

/**
 * 生产记录明细Service业务层处理
 * @author lmm
 * @date 2025-05-16
 */
@Service
public class ProduceRecordDetailServiceImpl implements IProduceRecordDetailService {
    @Resource
    private ProduceRecordDetailMapper produceRecordDetailMapper;

    /**
     * 查询生产记录明细
     * @param id 生产记录明细主键
     * @return 生产记录明细
     */
    @Override
    public ProduceRecordDetail selectById(String id) {
        return produceRecordDetailMapper.selectById(id);
    }

    /**
     * 查询生产记录明细列表
     * @param entity 生产记录明细
     * @return 生产记录明细
     */
    @Override
    public List<ProduceRecordDetail> selectList(ProduceRecordDetail entity) {
        return produceRecordDetailMapper.selectList(entity);
    }

    /**
     * 新增生产记录明细
     * @param entity 生产记录明细
     * @return 结果
     */
    @Override
    public int insert(ProduceRecordDetail entity) {
        if(StringUtils.isBlank(entity.getId())){
            entity.setId(IdUtils.fastSimpleUUID());
        }
                entity.setCreateBy(SecurityUtils.getUsername());
                entity.setCreateTime(DateUtils.getNowDate());
            return produceRecordDetailMapper.insert(entity);
    }

    /**
     * 修改生产记录明细
     * @param entity 生产记录明细
     * @return 结果
     */
    @Override
    public int update(ProduceRecordDetail entity) {
                entity.setUpdateBy(SecurityUtils.getUsername());
                entity.setUpdateTime(DateUtils.getNowDate());
        return produceRecordDetailMapper.update(entity);
    }

    /**
     * 批量删除生产记录明细
     * @param ids 需要删除的生产记录明细主键
     * @return 结果
     */
    @Override
    public int deleteByIds(String[] ids) {
        return produceRecordDetailMapper.deleteByIds(ids);
    }

    /**
     * 删除生产记录明细信息
     * @param id 生产记录明细主键
     * @return 结果
     */
    @Override
    public int deleteById(String id) {
        return produceRecordDetailMapper.deleteById(id);
    }
}
